package com.qlm.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.qlm.interceptor.AdminOperate2Interceptor;
import com.qlm.interceptor.AdminOperateInterceptor;
import com.qlm.interceptor.AuthInterceptor;
import com.qlm.service.IRecordService;
import com.qlm.service.impl.RecordServiceImpl;
import com.qlm.view.ResultMessage;

@Before(AuthInterceptor.class)
public class RecordController extends Controller {
	private static final Logger logger = LoggerFactory.getLogger(RecordController.class);
	private  IRecordService recordService = enhance(RecordServiceImpl.class);
	
	/**
	 * 进入产码记录页面
	 */
	public void getRecordList(){
		renderJsp("/page/recordList.jsp");
	}
	
	/**
	 * 产码记录列表分页
	 */
	public void recordListFound() {
		// 接收参数
		String aoData = getPara("aoData");
		logger.info("recordListFound param:aoData(" + aoData + ")");
		// 分页查询
		String jsonStr = recordService.getRecordList(aoData);
		logger.info("recordListFound return:jsonStr(" + jsonStr + ")");
		renderJson(jsonStr);
	}
	
	/**
	 * 二维码启用/禁用
	 */
	@Before({AdminOperateInterceptor.class,AdminOperate2Interceptor.class})
	public void setValid(){
		Integer id = getParaToInt("id");
		Integer valid = getParaToInt("valid");
		logger.info("setValid param:id(" + id + ")");
		logger.info("setValid param:valid(" + valid + ")");
		ResultMessage rm = recordService.setValid(id, valid);
		logger.info("setValid return:rm(" + rm + ")");
		renderJson(rm);
	}
	
}
